package com.snopy.scheduler;

import lombok.extern.slf4j.Slf4j;
import org.quartz.*;

import java.util.ArrayList;
import java.util.Date;

/**
 * @author snopy
 * @version 1.0.0
 * @classname HelloJob
 * @description
 * @email 77912204@qq.com
 * @date 2022/12/09 12:55
 */
@Slf4j
//@DisallowConcurrentExecution
public class HelloJob implements Job {

    String jobSays;
    float myFloatValue;
    ArrayList state;

    public HelloJob() {
    }

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {

        JobKey Key = context.getJobDetail().getKey();

        JobDataMap jobDataMap = context.getMergedJobDataMap();

        String job1Says = jobDataMap.getString("job1Says");
        String job2Says = jobDataMap.getString("job2Says");
        String job3Says = jobDataMap.getString("job3Says");

        float floatValue = jobDataMap.getFloat("myFloatValue");

        log.info("Instance key:{} of DumbJob says {} ,and val is {},executed {} times",Key,jobSays,floatValue,
                context.getJobDetail().getJobDataMap().entrySet().size()-2);
        log.info("job1:{},job2:{},job3:{}",job1Says,job2Says,job3Says);

        log.info("this class hashcode:{}",this.hashCode());
    }

    public void setJobSays(String jobSays) {
        this.jobSays = jobSays;
    }

    public void setMyFloatValue(float myFloatValue) {
        this.myFloatValue = myFloatValue;
    }

    public void setState(ArrayList state) {
        this.state = state;
    }
}
